﻿using System;
using System.Collections.Generic;
using System.Windows.Forms;
using Primitive.Mvvm.Framework.Interfaces;
using UIController.ViewModels;

namespace UIController.Views
{
    public partial class EmptyTaskView : UserControl, IWindowContainer
    {
        private TaskViewModel _model;
        private const string INITIAL_TASK_NAME = "Type task here...";

        public EmptyTaskView()
        {
            InitializeComponent();
            textBox.Text = INITIAL_TASK_NAME;
        }

        public bool Initialize(IModel model, IMediator mediator, List<Exception> exceptions)
        {
            _model = model as TaskViewModel;

            return Refresh(exceptions);
        }

        public void Clear(out Exception exception)
        {
            exception = null;
            _model = null;
        }

        private bool Refresh(List<Exception> exceptions)
        {
            //try
            //{
            //    var tree = _model.GetTreeElements();

            //    foreach (var treeNode in tree)
            //    {
            //        if (treeNode != null)
            //            treeView.Nodes.Add(treeNode);
            //    }
            //    return true;
            //}
            //catch (Exception ex)
            //{
            //    exceptions.Add(ex);
            //}

            return false;
        }

        private void textBox_Enter(object sender, EventArgs e)
        {
            if (textBox.Text == INITIAL_TASK_NAME)
                textBox.Text = string.Empty;
        }

        private void textBox_Leave(object sender, EventArgs e)
        {
            textBox.Text = INITIAL_TASK_NAME;
        }

        private void textBox_KeyDown(object sender, KeyEventArgs e)
        {
            
        }
    }
}
